// ignore_for_file: file_names, slash_for_doc_comments, must_call_super, unnecessary_overrides, override_on_non_overriding_member, must_be_immutable, prefer_const_constructors, prefer_typing_uninitialized_variables
import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:yc_plugin_learn/base/abstract/IFFScaffold.dart';
import 'package:yc_plugin_learn/base/demos/FFHeadListPage.dart';
import 'package:yc_plugin_learn/base/demos/FFListPage.dart';
import 'package:yc_plugin_learn/base/demos/FFPage.dart';
import 'package:yc_plugin_learn/base/tool/arouter/FFGoto.dart';
import 'package:yc_plugin_learn/base/widget/layout/FFLineContainer.dart';
import 'package:yc_plugin_learn/base/widget/layout/FFNavi.dart';
import 'package:yc_plugin_learn/base/widget/layout/FFTextButton.dart';
import 'package:yc_plugin_learn/base/widget/page/FFListScaffold.dart';

/**入口演示 */
class Start extends FFListScaffold {
  String? name;
  Start({Key? key, this.name}) : super(key: key);

  @override
  StartState createState() => StartState();
}

class StartState extends FFListScaffoldState {
  /**固定写法 */
  @override
  IFFScaffold get iffScaffold => this;
  @override
  Start get widget => super.widget as Start;
  /**固定写法end */

  @override
  void ffInitState() {
    super.ffInitState();
    initData();
  }

  @override
  Widget? ffNavi(BuildContext context) {
    return FFNaviFast.navi(
      context,
      "观看",
      color: Colors.white,
      haveLeading: false,
    );
  }

  @override
  Widget ffItem(BuildContext context, int index) {
    StartEntity entity = datas[index];
    return FFLineContainer(
      padding: EdgeInsets.symmetric(
        vertical: 10,
        horizontal: 20,
      ),
      children: [
        FFTextButton(
          text: entity.id,
          notes: "这是注释",
        ),
        FFTextButton(
          text: entity.title,
        ),
        FFTextButton(
          text: entity.info,
        ),
      ],
      onClick: () {
        if (entity.onClick != null) entity.onClick!();
      },
    );
  }
}

/**数据 */
extension StartStateDatas on StartState {
  void initData() {
    iffScaffold.ffPageStatus = FFPageStatus.result;
    datas = [
      StartEntity(
          id: "0",
          title: "插件演示",
          info: "example,去掉插件的注释，重新运行代码",
          onClick: () {}),
      StartEntity(
          id: "1",
          title: "FFPage",
          info: "普通页面，详情页面",
          onClick: () {
            FFGoto.gotoPage(context, FFPage());
          }),
      StartEntity(
          id: "2",
          title: "FFListPage",
          info: "普通列表页面",
          onClick: () {
            FFGoto.gotoPage(context, FFListPage());
          }),
      StartEntity(
          id: "3",
          title: "FFHeadListPage",
          info: "Head列表页面",
          onClick: () {
            FFGoto.gotoPage(context, FFHeadListPage());
          }),
    ];
  }
}

class StartEntity {
  String? id;
  String? title;
  String? info;
  Function? onClick;
  StartEntity({
    this.id,
    this.title,
    this.info,
    this.onClick,
  });
}
